package com.xunfang.controller;

import com.github.pagehelper.PageInfo;
import com.xunfang.bean.Owner;
import com.xunfang.bean.Result;
import com.xunfang.service.OwnerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author yellow Doctor
 * @date 2025-09-16
 * @desc https://blog.csdn.net/hekai7217
 */
@RestController
@Slf4j
@RequestMapping("/owner")
public class OwnerController {

    @Autowired
    private OwnerService ownerService;

    // 直接返回 Result(包裹集合)
    @GetMapping("/list/{currentPage}/{pageSize}")
    public Result selectList(@PathVariable Integer currentPage, @PathVariable Integer pageSize) {

        log.info("xxx");
        Result<PageInfo> result = ownerService.selectAllOwners(currentPage, pageSize);


        return result;
    }

    @PutMapping("")
    public Result updateOwner(@RequestBody Owner owner) {
        ownerService.updateOwner(owner);
        return Result.ok();
    }

}
